package org.huawei260.String;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @Auther: qingle
 * @Date: 2024/10/24-18:23
 * @Description:
 * @version: 1.0
 */
public class O0060_剩余可用字符集 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		scanner.close();

		// 按 '@' 分割全量字符集和已占用字符集
		String[] parts = input.split("@");
		String fullSet = parts[0];
		String usedSet = parts.length > 1 ? parts[1] : "";

		// 构建全量字符映射
		HashMap<String, Integer> fullHashMap = new HashMap<>();

		for (String entry : fullSet.split(",")) {
			String[] keyValue = entry.split(":");
			fullHashMap.put(keyValue[0], Integer.parseInt(keyValue[1]));
		}

		// 构建已占用字符映射
		HashMap<String, Integer> usedHashMap = new HashMap<>();

		for (String entry : usedSet.split(",")) {
			String[] keyValue = entry.split(":");
			usedHashMap.put(keyValue[0], Integer.parseInt(keyValue[1]));
		}

		// 计算剩余字符并输出结果
		// 如果包含在已占用字符中的key，则跳过
		// 如果已占用字符keyValue[0]超过或者等于全量字符，
		// 则从fullSet中移除，如果不超过，则从fullSet中减去已占用字符keyValue[1]
		for (String entry : fullSet.split(",")) {
			String[] keyValue = entry.split(":");
			if (usedHashMap.containsKey(keyValue[0]) && Integer.parseInt(keyValue[1]) > usedHashMap.get(keyValue[0])) {
				fullHashMap.put(keyValue[0], Integer.parseInt(keyValue[1]) - usedHashMap.get(keyValue[0]));
				continue;
			} else if (usedHashMap.containsKey(keyValue[0]) && Integer.parseInt(keyValue[1]) <= usedHashMap.get(keyValue[0])){
				fullHashMap.remove(keyValue[0]);
			} else{
				fullHashMap.put(keyValue[0], Integer.parseInt(keyValue[1]));
			}
//			fullHashMap.put(keyValue[0], Integer.parseInt(keyValue[1]));
		}

		// 拼接剩余字符
		StringBuilder result = new StringBuilder();
		for (String key : fullHashMap.keySet()) {
			result.append(key).append(":").append(fullHashMap.get(key)).append(",");
		}
		System.out.println(result.substring(0, result.length() - 1));

	}
}
